import { createBrowserRouter, Navigate, RouteObject } from 'react-router-dom'
import lazyLoad from './lazyLoad'
import { lazy } from 'react'
import AigcIcon from '@/components/AigcIcon'
import { HomeOutlined, UserOutlined } from '@ant-design/icons'

const Home = lazyLoad(lazy(() => import('@/view/Home')))
const Main = lazyLoad(lazy(() => import('@/view/Main')))
const About = lazyLoad(lazy(() => import('@/view/About')))
const NotFoundPage = lazyLoad(lazy(() => import('@/view/NotFound')))
const SystemInfo = lazyLoad(lazy(() => import('@/view/SystemInfo')))
const UserInfo = lazyLoad(lazy(() => import('@/view/Usercenter/UserInfo')))
const Money = lazyLoad(lazy(() => import('@/view/Usercenter/Money')))
const APIKey = lazyLoad(lazy(() => import('@/view/Usercenter/APIKey')))
const SecurityAudit = lazyLoad(lazy(() => import('@/view/SecurityAudit')))

const PIQuery = lazyLoad(lazy(() => import('@/view/PIQuery')))
const BigScreen = lazyLoad(lazy(() => import('@/view/BigScreen')))
export const routes: RouteObject[] = [
  {
    path: '/',
    element: Main,
    handle: {
      isShow: false
    },
    children: [
      {
        index: true,
        element: <Navigate to="/home" replace />,
        handle: {
          isShow: false
        }
      },
      {
        path: 'home',
        element: Home,
        handle: {
          isShow: true,
          name: '主页',
          icon: <HomeOutlined />
        }
      },
      {
        path: 'securityAudit',
        element: SecurityAudit,
        handle: {
          isShow: true,
          name: '安全审查',
          icon: <AigcIcon iconName="anquanshencha" />
        }
      },
      {
        path: 'PIquery',
        element: PIQuery,
        handle: {
          isShow: true,
          name: 'PIquery',
          icon: <AigcIcon iconName="query" />
        }
      },
      {
        path: 'usercenter',
        handle: {
          isShow: true,
          name: '用户中心',
          icon: <AigcIcon iconName="yonghuzhongxin" />
        },
        children: [
          {
            path: 'userInfo',
            element: UserInfo,
            handle: {
              isShow: true,
              name: '用户信息',
              icon: <UserOutlined />
            }
          },
          {
            path: 'money',
            element: Money,
            handle: {
              isShow: true,
              name: '余额管理',
              icon: <AigcIcon iconName="fenxiangyuejilu" />
            }
          },
          {
            path: 'apikey',
            element: APIKey,
            handle: {
              isShow: true,
              name: 'APIKey',
              icon: <AigcIcon iconName="API_KEY" />
            }
          }
        ]
      },
      {
        path: 'systemInfo',
        element: SystemInfo,
        handle: {
          isShow: true,
          name: '系统信息',
          icon: <AigcIcon iconName="system" />
        }
      },
      {
        path: 'about',
        element: About,
        handle: {
          isShow: true,
          name: '关于',
          icon: <AigcIcon iconName="about" />
        }
      },
      {
        path: '*',
        element: NotFoundPage,
        handle: {
          isShow: false
        }
      }
    ]
  },
  {
    path: '/bigscreen',
    element: BigScreen,
    handle: {},
    children: []
  }
]

export default createBrowserRouter(routes, {
  basename: '/'
})
